package com.gopay.common.domain.bank.wechat.scan.res;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.gopay.common.domain.bank.wechat.BaseReqMsg;
import com.thoughtworks.xstream.annotations.XStreamAlias;

/** 
 * @ClassName: ScanRefundQueryResMsg 
 * @Description: 威富通扫码支付退款查询响应类 
 * @author w_jiqing 
 * @date 2016年8月11日 下午1:30:16  
 */ 
@XStreamAlias("xml")
public class ScanRefundQueryResMsg extends BaseReqMsg{
    
    private static final long serialVersionUID = -3749413714712234558L;
    /**
     * 返回状态码
     */
    private String status;
    /**
     * 返回信息
     */
    private String message;
    /**
     * 业务结果
     */
    private String result_code;
    /**
     * 设备号
     */
    private String device_info;
    /**
     * 错误代码
     */
    private String err_code;
    /**
     * 新增字段
     */
    private String trade_type;
    /**
     * 错误描述
     */
    private String err_msg;
    public String getTrade_type() {
        return trade_type;
    }

    public void setTrade_type(String trade_type) {
        this.trade_type = trade_type;
    }

    /**
     * 威富通订单号
     */
    private String transaction_id;
    /**
     * 新增字段
     */
    private String appid;
    /**
     * 子商户是否关注
     */
    private String sub_is_subscribe;
    /**
     * 子商户 appid
     */
    private String sub_appid;
    /**
     * 用户 openid
     */
    private String sub_openid;
    /**
     * 商户订单号
     */
    private String out_trade_no;
    /**
     * 退款笔数
     */
    private int refund_count;
    
    private String out_transaction_id;
    private String trade_state_desc;
    private String total_fee;
    private List<ScanRefundItem> refundItems;

    /**
     * 因响应报文退款内容的元素名称不确定，因此需要将<out_refund_no_$n>元素之前的
     * xml报文截取出来，并转换成SdkRefundQueryResMsg类对象,之后将剩余的xml
     * 报文通过该方法映射为该类的集合元素
     * @param itemString 退款查询响应xml报文</refund_count>元素之后的
     * 所有xml元素的字符串
     */
    public void fillItem(String itemString) {
        refundItems = new ArrayList<ScanRefundItem>(refund_count);
        for (int i = 0; i < refund_count; i++) {
            ScanRefundItem item = new ScanRefundItem();
            if (itemString.contains("<out_refund_no_" + i + ">")) {
                item.setOut_refund_no(StringUtils.substringBetween(itemString, "<out_refund_no_" + i + "><![CDATA[", "]]></"));
            }
            if (itemString.contains("<refund_id_" + i + ">")) {
                item.setRefund_id(StringUtils.substringBetween(itemString, "<refund_id_" + i + "><![CDATA[", "]]></"));
            }
            if (itemString.contains("<refund_channel_" + i + ">")) {
                item.setRefund_channel(StringUtils.substringBetween(itemString, "<refund_channel_" + i + "><![CDATA[", "]]></"));
            }
            if (itemString.contains("<refund_fee_" + i + ">")) {
                item.setRefund_fee(StringUtils.substringBetween(itemString, "<refund_fee_" + i + "><![CDATA[", "]]></"));
            }
            if (itemString.contains("<coupon_refund_fee_" + i + ">")) {
                item.setCoupon_refund_fee(StringUtils.substringBetween(itemString, "<coupon_refund_fee_" + i + "><![CDATA[", "]]></"));
            }
            if (itemString.contains("<refund_time_" + i + ">")) {
                item.setRefund_time(StringUtils.substringBetween(itemString, "<refund_time_" + i + "><![CDATA[", "]]></"));
            }
            if (itemString.contains("<refund_status_" + i + ">")) {
                item.setRefund_status(StringUtils.substringBetween(itemString, "<refund_status_" + i + "><![CDATA[", "]]></"));
            }
            refundItems.add(item);
        }
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getResult_code() {
        return result_code;
    }

    public void setResult_code(String result_code) {
        this.result_code = result_code;
    }

    public String getDevice_info() {
        return device_info;
    }

    public void setDevice_info(String device_info) {
        this.device_info = device_info;
    }

    public String getErr_code() {
        return err_code;
    }

    public void setErr_code(String err_code) {
        this.err_code = err_code;
    }

    public String getTransaction_id() {
        return transaction_id;
    }

    public void setTransaction_id(String transaction_id) {
        this.transaction_id = transaction_id;
    }

    public String getOut_trade_no() {
        return out_trade_no;
    }

    public void setOut_trade_no(String out_trade_no) {
        this.out_trade_no = out_trade_no;
    }

    public int getRefund_count() {
        return refund_count;
    }

    public void setRefund_count(int refund_count) {
        this.refund_count = refund_count;
    }

    public List<ScanRefundItem> getRefundItems() {
        return refundItems;
    }

    public void setRefundItems(List<ScanRefundItem> refundItems) {
        this.refundItems = refundItems;
    }

    public String getAppid() {
        return appid;
    }

    public void setAppid(String appid) {
        this.appid = appid;
    }

	public String getErr_msg() {
		return err_msg;
	}

	public void setErr_msg(String err_msg) {
		this.err_msg = err_msg;
	}

	public String getSub_is_subscribe() {
		return sub_is_subscribe;
	}

	public void setSub_is_subscribe(String sub_is_subscribe) {
		this.sub_is_subscribe = sub_is_subscribe;
	}

	public String getSub_appid() {
		return sub_appid;
	}

	public void setSub_appid(String sub_appid) {
		this.sub_appid = sub_appid;
	}

	public String getSub_openid() {
		return sub_openid;
	}

	public void setSub_openid(String sub_openid) {
		this.sub_openid = sub_openid;
	}

	public String getOut_transaction_id() {
		return out_transaction_id;
	}

	public void setOut_transaction_id(String out_transaction_id) {
		this.out_transaction_id = out_transaction_id;
	}

	public String getTrade_state_desc() {
		return trade_state_desc;
	}

	public void setTrade_state_desc(String trade_state_desc) {
		this.trade_state_desc = trade_state_desc;
	}

	public String getTotal_fee() {
		return total_fee;
	}

	public void setTotal_fee(String total_fee) {
		this.total_fee = total_fee;
	}


}
